/** cc部门 */
import request from '@/utils/request'

/** 新增部门
 * @params {object} data
 */
export function postDepartmentInfo(data) {
  return request({
    method: 'POST',
    url: '/call-center/api/v1/departmentInfo',
    data
  })
}
/** 修改部门
 * @params {object} data
 */
export function putDepartmentInfo(data) {
  return request({
    method: 'PUT',
    url: '/call-center/api/v1/departmentInfo',
    data
  })
}
/** 查询所有部门
 */
export function getDepartmentInfo() {
  return request({
    method: 'GET',
    url: '/call-center/api/v1/departmentInfo/'
  })
}
/** 分页查询所有部门
 */
export function getDepartmentInfoPage(data) {
  return request({
    method: 'POST',
    url: '/call-center/api/v1/departmentInfo/page',
    data
  })
}
/** 删除部门
 * @params {string} id
 */
export function deleteDepartmentInfo(id) {
  return request({
    method: 'DELETE',
    url: `/call-center/api/v1/departmentInfo/${id}`
  })
}
/** 新增部门成员
 * @params {string} deptId
 * @params {array} data
 */
export function postMembers(deptId, data) {
  return request({
    method: 'POST',
    url: `/call-center/api/v1/departmentInfo/members/${deptId}`,
    data
  })
}

/**
 * 新增成员信息
 * @param {string} accountNo 用户账号
 * @param {array} data data
 */
export function postMembersDepts(accountNo, data) {
  return request({
    method: 'POST',
    url: `/call-center/api/v1/departmentInfo/members/depts/${accountNo}`,
    data
  })
}

/**
 * 删除部门下成员
 * @param {*} id 成员ID
 */
export function deleteMembers(ids) {
  return request({
    method: 'DELETE',
    url: `/call-center/api/v1/departmentInfo/members`,
    data: ids
  })
}

/**
 * 分页查询CC部门
 * @param {obj} data data
 */
export function getDeptNameInfo(data) {
  return request({
    url: `/call-center/api/v1/departmentInfo/page`,
    method: 'POST',
    data
  })
}

/**
 * 根据职员账号查询职员所属组织
 * @param {string} accountNo 员工账号
 */
export function getStaffDept(accountNo) {
  return request({
    url: `/call-center/api/v1/departmentInfo/members/depts/${accountNo}`,
    method: 'GET'
  })
}

/**
 * 按成员账号及部门ID集合批量删除账号所属的部门成员信息
 * @param {string} accountNO 用户账号
 * @param {array} data 部门ID
 */
export function deleteMembersByAccount(accountNO, data) {
  return request({
    url: `/call-center/api/v1/departmentInfo/members/account/${accountNO}`,
    method: 'delete',
    data
  })
}
/**
 * 分页查询所属组织下的成员
 * @param {string} deptId 部门id
 */
export function pageMember(deptId, data) {
  return request({
    url: `/call-center/api/v1/departmentInfo/member/page/${deptId}`,
    method: 'POST',
    data
  })
}
